/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package libudp;

import java.io.Serializable;

/**
 * The Syn object encapsulates a datagram message which syncs client and server
 * app.
 * 
 * The Syn object implements Serializable. This allows client applications to
 * serialize Ack object to bytes and deserialize bytes to Syn objects.
 * @author davidmessing
 */
public class Syn implements Serializable  {
    
    private long time;  // time in milliseconds that the Syn was created
    private int sequenceNum;    // Syn's are numbered (0, 1, 2...)
    private String message; // a short message

    //<editor-fold defaultstate="collapsed" desc="Getters and Setters">
    /**
     * Returns the Syn message.
     * @return
     */
    public String getMessage() {
        return message;
    }
    
    /**
     * Sets the message of Syn object.
     * @param message
     */
    public void setMessage(String message) {
        this.message = message;
    }
    
    /**
     * Returns the sequence number of Syn object.
     * @return
     */
    public int getSequenceNum() {
        return sequenceNum;
    }
    
    /**
     * Set the sequence number of Syn.
     * @param sequenceNum
     */
    public void setSequenceNum(int sequenceNum) {
        this.sequenceNum = sequenceNum;
    }
    
    /**
     * Returns the time assigned to Syn object.
     * @return
     */
    public long getTime() {
        return time;
    }
    
    /**
     * Sets the time of Syn object.
     * @param time
     */
    public void setTime(long time) {
        this.time = time;
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="Constructors">
    /**
     * Constructs a new default Syn object.
     */
    public Syn() {
        time = System.currentTimeMillis();
        sequenceNum = 0;
        message = "SYN";
    }
    
    /**
     * Constructs a new Syn object with specified parameters.
     * @param time
     * @param sequenceNum
     * @param message
     */
    public Syn(long time, int sequenceNum, String message) {
        this.time = time;
        this.sequenceNum = sequenceNum;
        this.message = message;
    }
    //</editor-fold>
    
    @Override
    public String toString() {
        return "SYN{" + "time=" + time + ", sequenceNum=" + sequenceNum + ", message=" + message + '}';
    }
}
